package com.example.myapplication2030606131wjw;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView textDuihuakuang;
    private Button tenGongyingshangChoose;
    private Button trnYuancailiaoChoose;
    private TextView textXiangmuLibiao;
    private Button trnOff;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        tenGongyingshangChoose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String[] gongyingshang={"新星汽车配件","枫叶汽车配件","天辉汽车配件","西未汽车配件"};
                new AlertDialog.Builder(MainActivity.this)
                  .setTitle("请选择供应商")
                  .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                      }
                  })
                  .setSingleChoiceItems(gongyingshang, 0, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int i) {
                           tenGongyingshangChoose.setText(gongyingshang[i]);
                      }
                  })

                        .create()
                        .show();
            }
        });
        trnYuancailiaoChoose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               String[] yuancailiao={"轿车引擎","轿车玻璃","轿车方向盘"};
                new AlertDialog.Builder(MainActivity.this)
                        .setTitle("请选择原材料")
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        })
                        .setSingleChoiceItems(yuancailiao, 0, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int i) {
                                trnYuancailiaoChoose.setText(yuancailiao[i]);
                            }
                        })
                        .create()
                        .show();
            }
        });
    }

    private void initView() {
        textDuihuakuang = (TextView) findViewById(R.id.text_duihuakuang);
        tenGongyingshangChoose = (Button) findViewById(R.id.ten_gongyingshang_choose);
        trnYuancailiaoChoose = (Button) findViewById(R.id.trn_yuancailiao_choose);
        textXiangmuLibiao = (TextView) findViewById(R.id.text_xiangmu_libiao);
        trnOff = (Button) findViewById(R.id.trn_off);
    }
}